Repository navigation
feat(agent-host): Pi diff cards and LSP diagnostics - #199
Merged
Merged
Conversation
Pi's edit and write calls reached the phone as a tool row and a result line only, while every other agent's file change also shows its diff. The driver now adds the diff card when the call finishes (only then has the change been applied): an edit's lines come from the unified patch Pi returns in its result details, with real context lines; a write returns no details, so its card is the written content, every line an addition. A failed change gets no card. A sub-agent's edits get theirs under the parent's call, the patch carried in its progress event. The unified-patch reader OpenCode's adapter had moves to sdk/transcript so both drivers use it. Co-Authored-By: Claude Code <[email protected]>
The fake model had no way to make an agent change a file, which is what
a diff card and post-edit diagnostics hang off. `/write <path> <content>`
calls the request's own `write` tool with `{path, content}` (Pi's
arguments, the only writer it was run against), a literal `\n` in the
content being a line break.
Co-Authored-By: Claude Code <[email protected]>
After a successful `edit` or `write`, the CodeDeck Pi extension has the project's language server check the file and appends its errors and warnings to the tool result, so the model sees a type error it just made in the same turn, and the phone shows it as part of the result. Servers, only ones already on the machine (project-local first, then PATH; nothing is installed): - TypeScript/JavaScript: typescript-language-server for a TypeScript that ships tsserver.js (up to 6.x), TypeScript 7's own `tsc --lsp` otherwise; a Node package runs with Pi's Node, an npm .cmd shim on PATH through a shell. - Python: basedpyright or Pyright, from the project's virtualenv, its node_modules, or PATH. - Rust: rust-analyzer from PATH (its own check, then cargo check's). How each server delivers diagnostics and when it is done differs, so the client follows what each did when run against the real binary: pull where the server offers it, wait out `$/progress` and a quiet window, wait for the push of a push-only server, re-pull after a project load or a `workspace/diagnostic/refresh`, and merge pull and push one problem each. Documents are keyed by path, since servers answer in VS Code's URI spelling (`file:///c%3A/...`). One server per project and language, kept for the session, stopped after ten idle minutes and when Pi exits; a server that cannot start is not retried for that project. A check waits at most 10 s (30 s for the change that starts the server); whatever has arrived by then is reported, marked unfinished. Only the changed file, errors and warnings, at most 20. Servers get Pi's environment without the provider profile's token. `CODEDECK_PI_LSP=off` turns it off. A general sub-agent's changes are checked too. Tests: piLsp.test.ts drives each server's behaviour through a shared fake (fakeLanguageServer.mjs, whose modes state what each real server was seen doing); the Pi fake-model test writes a TypeScript error through the real Pi and the real typescript-language-server, now a pinned devDependency, and checks the result and the diff card. Co-Authored-By: Claude Code <[email protected]>
PI.md says what a file change shows (the patch Pi applied, or the written content), and has a Diagnostics section: which servers check which files and where each is looked for, what makes a project's root, how long a check waits cold and warm, what is reported, that a server runs the project's build tooling without a profile's token, and the CODEDECK_PI_LSP=off switch. "No LSP diagnostics" leaves the list of what Pi does not have. Co-Authored-By: Claude Code <[email protected]>
deymosh
force-pushed
the
feat/pi-lsp-diagnostics
branch
from
November 18, 2026 09:28
597cf38 to
fed7fe3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pi gets two things every other agent's file changes already had or that Pi's own users get from oh-my-pi:
Diff cards. Pi's
editandwritereached the phone as a tool row and a result line, never as a diff. The driver now adds the diff card when the call finishes (only then has the change been applied): an edit's lines come from the unified patch Pi returns indetails.patch, with real context lines; a write shows the content it wrote. A failed change gets no card; a sub-agent's edit gets one under its parent's call. The unified-patch reader OpenCode's adapter had moved tosdk/transcriptso both drivers share it.LSP diagnostics. After a successful
editorwrite, the CodeDeck Pi extension has the project's language server check the file and appends its errors and warnings to the tool result: the model reads a type error it just made before its next step, and the phone shows it in the result.typescript-language-serverfor TypeScript ≤ 6; TypeScript 7's owntsc --lspnode_modules; the former alsoPATHbasedpyright-langserver, elsepyright-langserver.venv/venv,node_modules,PATHrust-analyzer(own check +cargo check)PATHNothing is installed. Design, after reading how oh-my-pi does it (
packages/coding-agent/src/lsp/) and probing each real server: an LSP client inside the extension (Node built-ins only), one server per project and language kept for the session (idle-stopped after 10 min, killed with Pi), pull where offered,$/progress+ a 300 ms quiet window, the push of a push-only server, a re-pull after a project load orworkspace/diagnostic/refresh, pull and push merged one problem each. 10 s per check (30 s for the change that starts the server); what arrived by then is reported, marked unfinished. Changed file only, errors and warnings, at most 20. Servers get Pi's environment without the provider profile's token.CODEDECK_PI_LSP=offturns it off.What the probes found that the code relies on (all in comments): TypeScript 7 ships no
tsserver.js, so typescript-language-server refuses it — TS 7 is its own server; Pyright and typescript-language-server answerfile:///C:/…asfile:///c%3A/…, so documents are keyed by path; Pyright speaks the OS locale unlessinitializesayslocale: "en"; rust-analyzer's pull is empty while it loads; rustup'srust-analyzerproxy without the component exits 1 (skipped, never retried that session).Also: a
/write <path> <content>scenario for the fake model.Cost
No wire change. A diff card is one more
diffentry per file change (capped at 200 lines like the other agents'). Diagnostics add at most 20 lines to an edit's result, only when there are errors or warnings. On the machine: one language-server process per project and language while in use; rust-analyzer runscargo checkon each change.Verification
./codedeck check --changed: green.piLsp.test.ts: server choice, the text the model reads, each server's behaviour through one shared fake whose modes state what each real server was seen doing, a server that cannot start, the deadline, the token stripped, the hook. Proven by breaking the URI keying, the token stripping, the re-pull and the give-up once each.piFakeModel.test.ts: the real Pi writes a TypeScript error; the real typescript-language-server (now a pinned devDependency) reportsTS2322in the result and the diff card shows. Fails with the hook removed.live-probewith--fake-modelthrough the built host: TypeScript 7 (tsc --lsp), basedpyright, and rust-analyzer (cold 13 s includingcargo check's borrow error E0505; warm < 1 s), each with its diff card.What review changed
A bug hunt found five real issues, each fixed in the LSP commit with a test that fails without the fix: a server frame whose body is not an object threw inside Pi's process; a server still initializing was not stopped when Pi exited, and a
.cmdshim's server survived a close (the tree is killed now); a stopped turn still waited up to 30 s for a starting server; a late push for the previous change could end the wait for this one (servers that push versions without$/progress); the project key was case-sensitive on Windows. CI's first run also showed the fake-model test's cleanup racing the server's exit on Windows (EBUSY): the cleanup retries.Not in this PR
Diagnostics for other languages (a Pi package can add them); errors the change causes in other files.
🤖 Generated with Claude Code